//全局环境变量
(function () {
    window.CONFIG = window.CONFIG || {};
    window.CONFIG.ENV = 1;
    var URL = window.location.href.split(":");

    if (CONFIG.ENV == 0) {
      //测试环境
      window.CONFIG.API = "http://127.0.0.1:7001/api/v1";
    } else if (CONFIG.ENV == 1) {
      //正式环境
      window.CONFIG.API = "https://taosha.club/api/v1";
    } else if (CONFIG.ENV == 2) {
      // Dev
      window.CONFIG.API = "http://127.0.0.1:7001/api/v1";
    }
    window.site_type = (URL[0] == 'https') ? window.CONFIG.SITE_HTTPS : window.CONFIG.SITE;
  }
)();

// 获取url参数通用参数
function getUrlInfo() {
  var url = window.document.location.href.toString();
  var u = url.split("?");
  if (typeof (u[1]) == "string") {
    u = u[1].split("&");
    var info = {};
    for (var i in u) {
      var j = u[i].split("=");
      info[j[0]] = decodeURIComponent(j[1]);
    }
    return info;
  } else {
    return {};
  }
}

/**
 * Toast提示
 */
function showToast(tip) {
  if ($('.toast-box').length) {
    $('.toast-box').remove();
  }

  const toastBox = `<div class="toast-box">
                      <span>${tip}</span>
                    </div>`;
  $('.taosha-container').prepend(toastBox);

  setTimeout(function () {
    $('.toast-box').remove()
  }, 1500);
}

